/**
**************************************************************************************
*Palisma - Secrets of the Illuminati is an open-source 2D RPG                        *
*Copyright (C) 2006, Tony Sparks                                                     *
*                                                                                    *
*This library is free software; you can redistribute it and/or                       *
*modify it under the terms of the GNU Lesser General Public                          *
*License as published by the Free Software Foundation; either                        *
*version 2.1 of the License, or (at your option) any later version.                  *
*                                                                                    *
*This library is distributed in the hope that it will be useful,                     *
*but WITHOUT ANY WARRANTY; without even the implied warranty of                      *
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                   *
*Lesser General Public License for more details.                                     *
*                                                                                    *
*You should have received a copy of the GNU Lesser General Public                    *
*License along with this library; if not, write to the Free Software                 *
*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA      *
**************************************************************************************
*/
#pragma once

#include "iview2d.h"
//#include <vector>

#include "modelmanager.h"
#include "../game/ientity.h"
#include "entityview.h"
#include "IRender.h"
#include <vector>
/**
========================
Manage all views in the game 
========================
*/
template<class T>
class QuadTree;
class ViewManager
{
public:
    /** Make this a singleton */
    static ViewManager* GetInstance() { return instance; }; 
    /** Update each view */
    void Update(IRender *r, ICamera* cam);
    /** Create the view */
    EntityView* CreateView( IEntity* ent);
    /** Remove the view */
    void RemoveView(int id);
    /** Remove the view */
    void RemoveView( CMMPointer<IView2D> &v) { RemoveView( v->GetRefID() ); };

    /** Set the Entity List */
    void SetEntityList( QuadTree<IEntity*> *quad ) { quadTree = quad; };
private:
    ViewManager(void);
    static ViewManager* instance;

    typedef std::vector< EntityView* > type_views;
    type_views m_views;

    ModelManager m_modelManager;
    // quick list to all entities in the world
    QuadTree<IEntity*> *quadTree;
public:
    virtual ~ViewManager(void);
};
